# This controller handles the login/logout function of the site.  
class SessionsController < ApplicationController
  # Be sure to include AuthenticationSystem in Application Controller instead
  include AuthenticatedSystem
  # If you want "remember me" functionality, add this before_filter to Application Controller
  before_filter :login_from_cookie

  def cklogin
	if logged_in?
		render :xml => '<login>success</login>'
	else
		render :xml => '<login>failure</login>'
	end
  end

  def create
    self.current_user = User.authenticate(params[:login], params[:password])
	if logged_in?
		render :xml => '<login>success</login>'
	else
		render :xml => '<login>failure</login>'
	end
  end

  def destroy
    self.current_user.forget_me if logged_in?
    cookies.delete :auth_token
    reset_session
    render :xml => ''
  end
end
